;;;; init-general  -  General Emacs settings 
;;;;
;;;;  Evgeniy Sharapov, evgeniy.sharapov@gmail.com 
;;;;
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;                     User Interface 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq
 frame-title-format '(buffer-file-name "%f" ("%b"))
 uniquify-buffer-name-style 'forward
 truncate-partial-width-windows nil
)
(setq-default
  display-warning-minimum-level 'error ;; Turn off anoying warning messages
)
(menu-bar-mode -1)
(mouse-wheel-mode t)
(tooltip-mode -1)
(tool-bar-mode -1)
(blink-cursor-mode -1)
(scroll-bar-mode -1)
(line-number-mode 1)
(display-time)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;                    Edit & View Buffers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq
 visible-bell t
 inhibit-startup-message t
 initial-scratch-message nil       ;; empty scratch buffer
 transient-mark-mode t
; shift-select-mode nil
 scroll-conservatively 50          ;; text scrolling
 scroll-preserve-screen-position nil
 scroll-margin 10
 scroll-step 1                     ;; Scroll by one line at a time
 imenu-auto-rescan t
 default-tab-width 4               ;; Tab is equal to four spaces
 yank-excluded-properties t
 echo-keystrokes 0.01              ;; see what's typed
 next-line-add-newlines nil        ;; don't add new lines when scrolling down
 require-final-newline t           ;; make sure file ends with NEWLINE
 mode-require-final-newline t      ;; same as above, set more generally
 delete-old-versions t             ;; delete excess backup versions
 kill-ring-max 1000                ;; long killring
 )
(setq-default
 transient-mark-mode t             ;; Highlighte region is turned on
 abbrev-mode t
 save-place t                      ;; save position in files
 case-fold-search t                ;; case INsensitive search
 indent-tabs-mode nil              ;; do not use tabs for indentation
)
;; Activate "dangerous" functions
(put 'eval-expression 'disabled nil)   
(put 'narrow-to-region 'disabled nil)  
(put 'downcase-region 'disabled nil)   
(put 'upcase-region 'disabled nil)     
(put 'capitalize-region 'disabled nil) 

(delete-selection-mode 1)
(show-paren-mode 1)               ;; Highlight matching parentheses when the point is on them.
(prefer-coding-system 'utf-8)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;                    Miscelaneous Settings 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq
 apropos-do-all t                 ;; apropos works better but slower
 backup-directory-alist `(("." . ,(expand-file-name (concat "~/.emacs.d/backups"))))
 make-backup-files nil            ;; no annoying about backing up file
 delete-old-versions t            ;; we don't need many backups
 save-place-file (convert-standard-filename (concat "~/.emacs.d/places"))
 delete-by-moving-to-trash t
 dired-recursive-copies 'top
 dired-recursive-deletes 'top
 safe-local-variable-values '((encoding . utf-8) (prompt-to-byte-compile))
 user-full-name "Evgeniy N. Sharapov"
 user-mail-address "eugene.sharapov.ext@siemens.com"
 browse-url-browser-function 'browse-url-firefox  ;; w3m doesn't work on Windows
 )
(defalias 'yes-or-no-p 'y-or-n-p) ;; short answer to qestions
(auto-compression-mode t)         ;; Transparently open compressed files
(global-auto-revert-mode 1)       ;; update all buffers (not only current) without asking 
(random t)                        ;; Seed the random-number generator
(server-start)
;; highlight file name parts if possible 
(when (fboundp 'file-name-shadow-mode)
  (file-name-shadow-mode 1))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;                    IDO & Buffer Switch 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'ido)
(ido-mode t)
(setq
 ido-enable-prefix nil
 ido-enable-flex-matching t
 ido-create-new-buffer 'always
 ido-use-filename-at-point t
 ido-max-prospects 10
 )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;                    Recentf Settings 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'recentf)
(recentf-mode 1)
(setq
 recentf-max-saved-items 5000
 recentf-max-menu-items 60
 recentf-exclude (append recentf-exclude '(".ftp:.*" ".sudo:.*" "*.ido.*"))
 recentf-keep '(file-remote-p file-readable-p)
 )

(provide 'init-general)
